package org.argeproje.resim.ui.component.filter;

import org.argeproje.resim.proc.data.KernelDA;
import org.argeproje.resim.proc.filter.ConvolutionPR;
import org.argeproje.resim.property.MatrixPRP;
import org.argeproje.resim.ui.model.ComponentItem;



public class ConvolutionCI extends ComponentItem {

	private static final long serialVersionUID = 1;
	
	private static final String KERNEL_PROP = "ConvolutionCI._kernel";	
	
	private String _kernel;	
	
	public ConvolutionCI()
	{		
		super();
		_name = "Convolution";
		_description = "Convolution with specified kernel";
	    initProc();
	}
	
	public void setKernel(String kernel)
	{
		_kernel = kernel;
	}
	
	public String getKernel()
	{
		return _kernel;
	}
	
	protected void initDescriptorList()
	{
		super.initDescriptorList();		
		_kernel = "[ 0,0,0; 0,1,0; 0,0,0 ]";
		registerProperty(new MatrixPRP(this,KERNEL_PROP,"Kernel","getKernel","setKernel"));
	}

	@Override
	public Class<ConvolutionCI> getComponentClass() {
		// TODO Auto-generated method stub
		return ConvolutionCI.class;
	}

	@Override
	public void initProc() {
		if(_processor == null)
		{
			_processor = new ConvolutionPR();			
		}
		_kernel = (((ConvolutionPR)_processor).getParamKernel()).toString();
	}
	public void updateProc() {
		if(_processor == null)
		{
			_processor = new ConvolutionPR();			
		}
		((ConvolutionPR)_processor).setParameters(new KernelDA(_kernel));
	}
}